package visitorpack;

public class EngineInventory implements EngineVisitor {
    private int camshaftCount;
    private int pistonCount;
    private int sparkPlugCount;
 
    public EngineInventory() {
        camshaftCount = 0;
        pistonCount = 0;
        sparkPlugCount = 0;
    }
 
    public void visit(Camshaft p) {
        camshaftCount++;
    }
 
    public void visit(Engine e) {
        System.out.println("The engine has: " + camshaftCount + " camshaft(s), " + pistonCount + " piston(s), and " + sparkPlugCount + " spark plug(s)");
    }
 
    public void visit(Piston p) {
        pistonCount++;
    }
 
    public void visit(SparkPlug sp) {
        sparkPlugCount++;
    }
}
